package ar.com.equis.arquitectura.preloader {
	import flash.events.ErrorEvent;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	
	/**
	 * Item to use in @see ar.com.mindset.flexy.util.AsyncMultiCaller. Recives a function that returns an object instead of the object directly.
	 * Otherwise, the same as @see ar.com.mindset.flexy.preloader.LazyBatchItem.
	 */
	public class LazyBatchItem extends BatchItem {
		
		private var hostBuilder:Function;
		
		public function LazyBatchItem(_hostBuilder:Function, _callMethodName:String, _eventName:String, _requires:Array = null) {
			super(null, _callMethodName, _eventName, _requires);
			this.hostBuilder = _hostBuilder;
		}

		public override function call(_preCallback:Function):void {
			host = hostBuilder();
			super.call(_preCallback);
		}


		public override function toString():String {
			return super.toString() + "; Builder: " + hostBuilder;
		}

	}
}